package com.example.order.controller;

import com.example.order.model.DishInfo;
import com.example.order.service.DishService;
import com.example.order.tools.ResponseBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/dish")
public class DishController {
    @Autowired
    private DishService dishService;

    @RequestMapping("/list")
    public ResponseBody getList(){
        List<DishInfo> data = dishService.getList();
        return new ResponseBody(0 , "" , data);
    }

    /**
     * 新增菜品
     * @return
     */
    @RequestMapping("/add")
    public ResponseBody add(DishInfo dish){
        int data = 0;
        data = dishService.add(dish);
        return new ResponseBody(0 , "" , data);
    }

    /**
     * 菜品下架
     * @param id
     * @return
     */
    @RequestMapping("/del")
    public ResponseBody del(int id){
        int data = 0;
        data = dishService.del(id);
        return new ResponseBody(0 , "" , data);
    }
}
